import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:my_app/base/foundation/jd_colors.dart';
import 'package:my_app/modules/widgets/base_dialog.dart';

class TDAgreementDialog {
  show(BuildContext context,
      {VoidCallback? agreeCallBack, VoidCallback? cancelCallBack}) {
    return showGeneralDialog(
      barrierDismissible: false,
      context: context,
      barrierLabel: '',
      barrierColor: const Color(0xFF000000).withOpacity(0.8),
      pageBuilder: (BuildContext context, Animation<double> animation,
          Animation<double> secondaryAnimation) {
        return _buildContent(context,
            agreeCallBack: agreeCallBack, cancelCallBack: cancelCallBack);
      },
    );
  }

  _buildContent(BuildContext context,
      {VoidCallback? agreeCallBack, VoidCallback? cancelCallBack}) {
    return BaseDialog(
        title: '请阅读并同意以下权益',
        okCallBack: agreeCallBack,
        cancelCallBack: cancelCallBack,
        customChild: Padding(
          padding: const EdgeInsets.fromLTRB(24, 0, 24, 0),
          child: Text.rich(
            TextSpan(text: '为了更好地体验xxxx服务，请查看并同意', children: [
              TextSpan(
                  text: '《用户协议》',
                  recognizer: TapGestureRecognizer()
                    ..onTap = () {
                      // RouterContractPage.instance.webViewPage.push(context, {
                      //   "title": "用户服务协议",
                      //   "url": kConfigKeys.registerAgreement,
                      // });
                    },
                  style:
                      const TextStyle(color: JDColors.cF08223, fontSize: 11)),
              const TextSpan(text: '和'),
              TextSpan(
                text: '《隐私政策》',
                recognizer: TapGestureRecognizer()
                  ..onTap = () {
                    // RouterContractPage.instance.webViewPage.push(context, {
                    //   "title": "用户隐私政策",
                    //   "url": kConfigKeys.privacyAgreement,
                    // });
                  },
                style: const TextStyle(color: JDColors.cF08223, fontSize: 11),
              ),
            ]),
            style: const TextStyle(color: JDColors.c999999, fontSize: 11),
          ),
        ));
  }
}
